package com.v2.k47;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 测试@Autowired2 修饰普通方法
 * xml时，下面两个要同时用，也可以只用<context:component-scan>；但不能只用<context:annotation-config>（这个扫描不了bean）
 * <context:annotation-config></context:annotation-config>
 * 	<context:component-scan base-package="com.v2.k47"/>
 */
public class Test {

	public static void main(String[] args) {

		ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-k47.xml");

		Student s = (Student)applicationContext.getBean("student");
		System.out.println(s);
		System.out.println(s.ppp);

//		System.out.println(applicationContext.getBean("iii")); //报错 No bean named 'iii' available
		System.out.println(applicationContext.getBean(Person.class)); //跟s.ppp是同一对象

	}

}
